package com.gewu.pm.ui.activity.order;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.gewu.pm.R;
import com.gewu.pm.app.AppActivity;
import com.gewu.pm.other.IntentKey;
import com.gewu.pm.ui.adapter.order.PendingPaymentOrderDetailsAdapter;
import com.hjq.base.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 代支付订单详情
 */
public class PendingPaymentOrderDetailsActivity extends AppActivity implements BaseAdapter.OnItemClickListener {
    private RecyclerView mRecyclerView;
    TextView tvSubmit;
    private PendingPaymentOrderDetailsAdapter mAdapter;

    public static void start(Context context, String id) {
        Intent intent = new Intent(context, PendingPaymentOrderDetailsActivity.class);
        intent.putExtra(IntentKey.ID, id);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_pending_payment_order_details;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mRecyclerView = findViewById(R.id.rv_list);
        tvSubmit = findViewById(R.id.tv_bottom_button);
        // 设置RecyclerView
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        mAdapter = new PendingPaymentOrderDetailsAdapter(getContext());
        mAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mAdapter);

        setOnClickListener(tvSubmit);
    }

    @Override
    protected void initData() {
        List<String> list = new ArrayList<>();
        list.add("¥1000.00");
        list.add("¥2000.00");
        list.add("¥3000.00");
        mAdapter.setData(list);
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        if (view == tvSubmit) {
            PayOrderActivity.start(getActivity(), "¥300.00");
        }
    }

    @Override
    public void onItemClick(RecyclerView recyclerView, View itemView, int position) {
        toast(mAdapter.getItem(position));
    }
}